import { _decorator, Animation, AnimationClip, AnimationState } from "cc";
import State from "../Base/State";
import StateMachine, { getInitParamsTrigger } from "../Base/StateMachine";

import { EAnimationPlayMode, EState, EntityType, EParamsName } from "../Config/Enum";
const { ccclass } = _decorator;

// 给只需要idle状态的状态机用
@ccclass("IdleStateMachine")
export class IdleStateMachine extends StateMachine {
  speed: any;
  animationPlayMode: EAnimationPlayMode
  wrapMode

  
  init(type: EntityType, speed:number, animationPlayMode:EAnimationPlayMode) {

    
    this.type = type;
    
    this.animationComponent = this.node.getComponent(Animation) || this.node.addComponent(Animation);

    this.speed = speed
    this.animationPlayMode = this.wrapMode = animationPlayMode;

        
    this.initParams();
    this.initStateMachines();
    //this.initAnimationEvent();

  }

  initParams() {
    this.params.set(EParamsName.Idle, getInitParamsTrigger());

  }

  initStateMachines() {
    this.stateMachines.set(EParamsName.Idle, new State(this, `${this.type}${EState.Idle}`, this.wrapMode, false, this.speed));
  }



  run() {
    // console.log("this.currentState", this.currentState);
    switch (this.currentState) {

      case this.stateMachines.get(EParamsName.Idle):
        break;
      default:
        this.currentState = this.stateMachines.get(EParamsName.Idle);
        break;
    }
  }
}
